package blackithei.TCP;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo3 {
    public static void main(String[] args) throws IOException {
        ServerSocket so=new ServerSocket(10001);
        //连接配对
        Socket accept = so.accept();
        //网络流
        BufferedInputStream bf=new BufferedInputStream(accept.getInputStream());
        //本地流
        BufferedOutputStream buff=new BufferedOutputStream(new FileOutputStream("day15\\change2.doc"));
        int by;
        while((by=bf.read())!=-1){
            buff.write(by);
        }

        //反馈
        BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(accept.getOutputStream()));
        bw.write("大漠孤烟直");
        bw.flush();
        bw.close();

        buff.close();
        bf.close();
        accept.close();
        so.close();
    }
}
